// 定义 父类 列表
var parent_type_arr = [['','全部'],['1','原材料'],['2','产品'],['3','耗材'],['4','工具'],['5','包装物料'],['6','劳保用品'],['7','办公用品'],['8','设备']];
function create_parent_type_list(){
	var parent_type_val = '';
	for(var i=0;i<parent_type_arr.length;i++){
		parent_type_val = parent_type_val + '<option value="'+parent_type_arr[i][0]+'" >'+parent_type_arr[i][1]+'</option>';
	}
	
	$('#parent_type').html(parent_type_val);
};
function selected_items_list(){
	var selected_items_box = document.getElementsByName('selected_items');
	var selected_items_val = new Array();
	var j = 0;
	for(var i=0;i<selected_items_box.length;i++){
		var box_item = selected_items_box[i];
		if(box_item.checked){
			var td_nade = box_item.parentNode.parentNode.getElementsByTagName('td');
			var id = box_item.value;
			var name = td_nade[2].innerHTML;
			var norm = td_nade[4].innerHTML;
			var amount = td_nade[5].innerHTML;
			var _unit = td_nade[6].innerHTML;
			selected_items_val[j] = id+'?'+name+'?'+norm+'?'+_unit+'?'+amount;
			j++;
		}
	}
	window.returnValue = selected_items_val;
	window.close();
};
function select_all(){
	var is_checked = document.getElementById('select_all').checked;
	var selected_items = document.getElementsByName('selected_items');
	for(var i=0;i<selected_items.length;i++){
		selected_items[i].checked=is_checked;
	}
};
function selectMerchandiseUnit(){
	var url = '/storage/manager/pages/merchandise.do?method=selectMerchandiseUnit&d=' + new Date();

	$.getJSON(url, {}, function(data){
		var merchandise_unit = '';
		for(var i=0;i<data.length;i++){
			merchandise_unit = merchandise_unit + '<option value="'+data[i][0]+'" >'+data[i][1]+'</option>';
		}
		$('#merchandise_unit').html(merchandise_unit);
	});
};
function selectMerchandiseType(){
	var parent_type = $('#parent_type').val();
	if(parent_type!=''){
		var url = '/storage/manager/pages/merchandise.do?method=selectMerchandiseType&d=' + new Date();
		url = url + '&parent_type=' + parent_type;

		$.getJSON(url, {}, function(data){
			var merchandise_type = '';
			for(var i=0;i<data.length;i++){
				merchandise_type = merchandise_type + '<option value="'+data[i][0]+'" >'+data[i][1]+'</option>';
			}
			$('#merchandise_type').html(merchandise_type);
		});
	}else{
		$('#merchandise_type').html('<option value="" ></option>');
	}
	
};